package com.penghaisoft.microwms.product.service.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.common.dto.ProCountingDto;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.common.wms.model.ProCountingRecords;
import com.penghaisoft.microwms.product.dao.ProCountingRecordsMapper;
import com.penghaisoft.microwms.product.service.IProCountingRecordsService;

/**
 * <p>
 * 业务逻辑实现类
 * </p>
 * 
 * @author
 * @createDate 
 **/
@Service("proCountingRecordsService")
public class ProCountingRecordsServiceImpl extends BaseService implements IProCountingRecordsService{
		@Resource
		private ProCountingRecordsMapper proCountingRecordsMapper;
		
	  /**
	   * 新增记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp create(ProCountingRecords proCountingRecords){
			Integer updateCnt = proCountingRecordsMapper.create(proCountingRecords);
			if (updateCnt.intValue() == 1) {
				return success();
			} else {
				return fail("条码盘点记录创建失败");
			}
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp delete(ProCountingRecords proCountingRecords){
			proCountingRecordsMapper.delete(proCountingRecords);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param pager
	   * @param baseResource
	   * @return
	   */
		@Override
		public Pager<ProCountingRecords> findListByCondition(int page, int rows,ProCountingRecords condition){
		    Pager<ProCountingRecords> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
    		condition.preQuery();
			List<ProCountingRecords> records = proCountingRecordsMapper.queryList(pager,condition);
			long size = proCountingRecordsMapper.queryCount(condition);
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public ProCountingRecords findById(String id){
			return proCountingRecordsMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp update(ProCountingRecords proCountingRecords){
			proCountingRecordsMapper.updateBySelect(proCountingRecords);
			return success();
		}

	@Override
	public List<ProCountingRecords> queryByAny(ProCountingRecords proCountingRecords) {
		
		return proCountingRecordsMapper.queryByAny(proCountingRecords);
	}

	@Override
	public List<ProCountingRecords> queryWin(ProCountingDto proCountingDto) {
		
		return proCountingRecordsMapper.queryWin(proCountingDto);
	}

	@Override
	public Long queryCount(ProCountingRecords proCountingRecords) {
		return proCountingRecordsMapper.queryCount(proCountingRecords);
	}

}
